const fs = require('fs')

function readFile(path) {
  return new Promise (function (resolve, reject) {
    fs.readFile(path, 'utf-8', (err, data) => {
      if (err) return reject(err)
      resolve(data)
    })
  })
}

function writeFile(path, txt) {
  return new Promise (function (resolve, reject) {
    fs.writeFile(path, txt, (err, data) => {
      if (err) return reject(err)
      resolve(data)
    })
  })
}

module.exports = {
  readFile,
  writeFile
};
